<?php
/**
 * 类型控制器
 */
class TypeController extends AuthController{
	private $model;
	public function __init(){
		parent::__init();
		$this->model=K('Type');
	}
	/*
	 * 类型列表
	 * */
	public function index(){
		$this->assign('typeData',$this->model->all());
		$this->display();
	}
	
	/*
	 * 添加类型
	 * */
	public function addType(){
		if(IS_POST){
			if(!$this->model->addType()) $this->error($this->model->error);
			$this->success('添加成功',U('index'));
		}
		$this->display();
	}
	
	
	/*
	 * 编辑类型
	 * */
	public function editType(){
		if(IS_POST){
			$this->model->update();
			$this->success('修改成功',U('index'));
		}
		$tpid=Q('get.tpid',0,'intval');
		$this->assign('typeData',$this->model->where("tpid={$tpid}")->find());
		$this->display();
	}

	/*
	 * 删除类型
	 * */
	public function del(){
		$tpid=Q('get.tpid',0,'intval');
		$this->model->where("tpid={$tpid}")->delete();
		$this->success('删除成功',U('index'));
	}
	
	
	
	
	
	
	
}
    
    
    
?>
